package com.jjwt.demo;

import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

import java.util.Date;

public class CreateJwtDemo2 {
    public static void main(String[] args) {
        Long times = System.currentTimeMillis();
        Date date = new Date(times + 180 * 1000);
        JwtBuilder jwtBuilder = Jwts.builder().setId("8888")
                .setIssuedAt(new Date())
                .setSubject("小明")
                .setExpiration(date)
                .claim("roles","admin")
                .claim("logo","logo.png")
                .signWith(SignatureAlgorithm.HS256,"zelin");
        String compact = jwtBuilder.compact();
        System.out.println(compact);

    }
}
